#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QtSerialPort/QSerialPortInfo>
#include <QtSerialPort/QtSerialPort>
#include <QFileDialog>
#include <QMessageBox>
#include <QCloseEvent>
#include <QGraphicsScene>
#include <QMovie>
namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

    void serial_write(unsigned char *buf, int len);
    void send_bootloader(void);
    int check_ack(unsigned char *buf);
    int check_cmd(unsigned char *buf, int len);

private slots:
    void on_serial_open_pushButton_clicked();
    void timerOut_slot(void);
    void timer2Out_slot(void);

    void on_pushButton_clicked();

    void on_pushButton_2_clicked();

    void on_open_file_pushButton_clicked();

    void on_download_pushButton_clicked();

    void read_serial_slot(void);

    void on_horizontalSlider_sliderReleased();

    void on_horizontalSlider_valueChanged(int value);

//    void on_pushButton_3_clicked();

    void on_pushButton_4_clicked();

//    void on_pushButton_5_clicked();

    void on_pushButton_5_clicked();

    void on_lineEdit_textChanged(const QString &arg1);

    void on_tabWidget_currentChanged(int index);

private:
    Ui::MainWindow *ui;

    QSerialPort serial;
    QTimer timer;
    QTimer timer2;
    QStringList serial_Name_list;

    int packet_id;
    int open_flag;
    int start_flag;
    int file_len;
    char tx_data[100 * 1024];
    int write_index;

    int flag;

    int close_flag;

    float v;
    float c;
    float p;
    float e;

    QGraphicsScene *scene;
};

#endif // MAINWINDOW_H
